package com.qingcloud.adminbackend.enums;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 设计器角色枚举
 */
public enum UcRoleEnum {

    OWNER(1, "拥有者"),
    MANAGER(2, "管理员"),
    DEVELOPER(3, "开发者"),
    TEST(4, "体验者"),
    ORG_MANAGE(5, "企业管理员"),
    ENG(6, "工程师");

    public Integer code;

    public String name;

    UcRoleEnum(Integer code, String name) {
        this.code = code;
        this.name = name;
    }

    /**
     * 拥有者可授权的角色
     */
    public static List getOwnerRole() {
        List<Map<String, Object>> list = new ArrayList<>();
        for (UcRoleEnum value : UcRoleEnum.values()) {
            if (value.code < UcRoleEnum.ORG_MANAGE.code) {
                Map<String, Object> map = new HashMap<>();
                map.put("code", value.code);
                map.put("name", value.name);
                list.add(map);
            }
        }
        return list;
    }

    /**
     * 其他可授权的角色
     */
    public static List getManageRoles() {
        List<Map<String, Object>> list = new ArrayList<>();
        for (UcRoleEnum value : UcRoleEnum.values()) {
            if (value.code < UcRoleEnum.ORG_MANAGE.code && value.code > UcRoleEnum.OWNER.code) {
                Map<String, Object> map = new HashMap<>();
                map.put("code", value.code);
                map.put("name", value.name);
                list.add(map);
            }
        }
        return list;
    }

}
